<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>添加送实物兑换</title>
    <script type="text/javascript">
        var prizeId = '${prize.id }';
        var selectItemDialog = null;
        $(document).ready(function () {
            //保存奖品
            $("#savePrize").click(function () {
                $("#container").mask("正在保存...");
                obz.ajaxJson(obz.ctx + "/prize/save", $("#prizeForm").serialize(), function (data) {
                    $("#container").unmask();
                    var response = data;
                    if (data.code != 200) {
                        obz.showMessage(response.msg);
                    } else {
                        if (addPrizeDailog != null) addPrizeDailog.close();
                        //保存成功,跳转到列表页
                        obz.showMessage(response.data, function () {
                            searchPrizes();
                        }, function () {
                        });
                    }
                }, function () {
                    $("#container").unmask();
                    $("[id^='error_']").each(function () {
                        $(this).removeClass("has-error");
                        $(this).find("label").empty();
                    });
                });
            });

            $("#selectItems").click(function () {
                selectItemDialog = BootstrapDialog.show({
                    size: BootstrapDialog.SIZE_WIDE,
                    title: "商品列表",
                    message: $('<div></div>').load('${webctx}/prize/showItems')
                });
            });

            if ($("#myselectItemImg").attr("src") != null && $("#myselectItemImg").attr("src") != "") {
                $("#myselectItemImg").show();
            }
        });
    </script>
</head>
<body class="fixed-sidebar full-height-layout gray-bg">
<div class="panel-body">
    <div class="alert alert-success">
        <strong>提示:</strong> 您可任意填写奖品，如：电影票，彩票等。系统不自动发奖，用户中奖后由您在后台手动发奖.
    </div>

    <form name="prizeForm" id="prizeForm" action="" method="post" class="form-horizontal ">
        <input type="hidden" name="prize_type_id" id="prize_type_id" value="${prizeTypeId }"/>
        <input type="hidden" name="active" id="active" value="${prize.active }"/><!-- 默认为1，值为0的时候表示删除，删除后用户不可见 -->
        <input type="hidden" name="id" id="id" value="${prize.id }"/>
        <input type="hidden" id="prize_single_cash" name="prize_single_cash" value="0">
        <div class="form-group" style="display: none;">
            <label class="col-md-2 control-label"></label>
            <div class="col-md-9">
                <a id="selectItems" class="form-control-static" href="javascript:void(0)">选择已有商品做奖品</a>
            </div>
        </div>
        <div class="form-group">
            <label class="col-md-2 control-label">奖品名称<span style="color: red;"><em>*</em></span></label>
            <div class="col-md-5" id="error_prize_name">
                <input type="text" id="prize_name" name="prize_name" value="${prize.prizeName }" class="form-control"
                       placeholder="比如填写奖励一个iphone6手机">
                <label class="control-label" for="prize_name"></label>
            </div>
        </div>
        <div class="form-group">
            <label class="col-md-2 control-label">奖品总数量<span style="color: red"><em>*</em></span></label>
            <div class="col-md-5" id="error_publish_count">
                <input type="text" id="publish_count" name="publish_count" value="${prize.publishCount }"
                       class="form-control" placeholder="比如填写100" onkeyup="value=value.replace(/[^\d]/g,'')">
                <label class="control-label" for="publish_count"></label>
            </div>
            <!-- <span class="alert-success">
            	<i class="fa fa-info-circle"></i>指定日期签到提高店铺会员积极性，再好不过啦
            </span> -->
        </div>
        <div class="form-group">
            <label class="col-md-2 control-label">奖品价值（元）<span style="color: red"><em>*</em></span></label>
            <div class="col-md-5" id="error_prize_price">
                <input type="text" id="prize_price" name="prize_price" value="${prize.prizePrice }" class="form-control"
                       placeholder="比如填写100" onkeyup="value=value.replace(/[^\d]/g,'')">
                <label class="control-label" for="prize_price"></label>
            </div>
        </div>
        <div class="form-group" style="display: none;">
            <label class="col-md-2 control-label">图片</label>
            <div class="col-md-5" id="error_prize_img">
                <input type="text" id="prize_img" name="prize_img" value="${prize.prizeImg }" class="form-control"
                       placeholder="请复制淘宝图片空间图片链接地址">
                <label class="control-label" for="prize_img"></label>
            </div>
            <span class="alert-success">
              <span><i class="fa fa-info-circle"></i>请到淘宝<a class="blue"
                                                            href="http://tadget.taobao.com/redaction/manager.htm"
                                                            target="_blank">图片空间</a>选择图片，再复制链接到此处。</span>
            </span>
        </div>
        <div class="form-group">
            <label class="col-lg-2 col-md-2 col-sm-12 control-label">有效时间</label>
            <div class="col-lg-10 col-md-10">
                <div class="row">
                    <div class="col-lg-3 col-md-3">
                        <input type="text" id="start_date" name="start_date" style="width: 160px; cursor: pointer;"
                               readonly="readonly"
                               onfocus="WdatePicker({isShowClear:false,readOnly:true,dateFmt:'yyyy-MM-dd %H:%m:%s',minDate:'%y-%M-%d %H:%m:%s',maxDate:'#F{$dp.$D(\'end_date\')}'})"
                               class="Wdate" value="${prize.startDate }"/>
                    </div>
                    <div class="col-lg-3 col-md-3">
                        <input type="text" id="end_date" name="end_date" style="width: 160px; cursor: pointer;"
                               readonly="readonly"
                               onfocus="WdatePicker({isShowClear:false,readOnly:true,dateFmt:'yyyy-MM-dd %H:%m:%s',maxDate:'#F{$dp.$D(\'start_date\',{d:28, H:23, m:59, s:59});}'})"
                               class="Wdate" value="${prize.endDate }"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-md-2 control-label">领取说明</label>
            <div class="col-md-5">
                <textarea id="prize_memo" name="prize_memo" rows="3" class="form-control" placeholder="">${prize.prizeMemo }</textarea>
            </div>
        </div>
    </form>
</div>
<div class="panel-footer" align="center">
    <button id="savePrize" class="btn btn-sm btn-success"><i class="fa fa-dot-circle-o"></i>提交</button>
</div>
</body>
</html>